
// 封装request
const accessKey = "";
const BASE_URL = "https://tea.qingnian8.com/api/bizhi"
export function request(config = {}) {
	let {
		url,
		method = "GET",
		data = {},
		header = {}
	} = config;
	url = BASE_URL + url;
	header["access-key"] = accessKey
	return new Promise((resolve, reject) => {
		uni.request({
			url,
			method,
			header,
			data,
			success: (res) => {
				if (res.data.errCode === 0) {
					resolve(res.data)
				} else {
					uni.showToast({
						title:res.data.errMsg,
						icon:"none"
					})
					reject(res.data)
				}
			},
			fail: (err) => {
				reject(err)
			}
		})
	})	
}